<!-- <div class="emails index">
	<h2><?php echo __('Emails'); ?></h2>
	<table cellpadding="0" cellspacing="0">
	<thead>
	<tr>
			<th><?php echo $this->Paginator->sort('id'); ?></th>
			<th><?php echo $this->Paginator->sort('title'); ?></th>
			<th><?php echo $this->Paginator->sort('content'); ?></th>
			<th><?php echo $this->Paginator->sort('created'); ?></th>
			<th><?php echo $this->Paginator->sort('modifired'); ?></th>
			<th><?php echo $this->Paginator->sort('list_group_send'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	</thead>
	<tbody>
	<?php foreach ($emails as $email): ?>
	<tr>
		<td><?php echo h($email['Email']['id']); ?>&nbsp;</td>
		<td><?php echo h($email['Email']['title']); ?>&nbsp;</td>
		<td><?php echo h($email['Email']['content']); ?>&nbsp;</td>
		<td><?php echo h($email['Email']['created']); ?>&nbsp;</td>
		<td><?php echo h($email['Email']['modifired']); ?>&nbsp;</td>
		<td><?php echo h($email['Email']['list_group_send']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('View'), array('action' => 'view', $email['Email']['id'])); ?>
			<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $email['Email']['id'])); ?>
			<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $email['Email']['id']), array(), __('Are you sure you want to delete # %s?', $email['Email']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</tbody>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
</div>
<div class="actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('New Email'), array('action' => 'add')); ?></li>
		<li><?php echo $this->Html->link(__('List Customers'), array('controller' => 'customers', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Customer'), array('controller' => 'customers', 'action' => 'add')); ?> </li>
	</ul>
</div>
 -->

 <section id="content">
        <section class="main padder">
            <div class="clearfix">
                <h4><i class="fa fa-list"></i>List Emails</h4>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <div class="panel-body">
                            <div class="row text-small">
                                <div class="col-sm-4 m-b-mini">

                                </div>
                                <div class="col-sm-4 m-b-mini">
                                    <div class="btn-group" data-toggle="buttons">
                                        <label class="btn btn-sm btn-white active">
                                            <input type="radio" name="options" id="option1">
                                            Day </label>
                                        <label class="btn btn-sm btn-white">
                                            <input type="radio" name="options" id="option2">
                                            Week </label>
                                        <label class="btn btn-sm btn-white">
                                            <input type="radio" name="options" id="option2">
                                            Month </label>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="input-group">
                                        <input type="text" class="input-sm form-control" placeholder="Search">
                                        <span class="input-group-btn">
                                            <button class="btn btn-sm btn-white" type="button">Go!</button>
                                        </span></div>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped b-t text-small">
                                <thead>
                                    <tr>
                                        <th width="20">
                                            <input type="checkbox"></th>
                                        <th class="th-sortable" data-toggle="class">Email Title <span class="th-sort"><i class="fa fa-sort-down text"></i><i class="fa fa-sort-up text-active"></i><i class="fa fa-sort"></i></span></th>
                                        <th>No. of Emails sent</th>
                                        <th>No. of open</th>
                                        <th width="300px !important">View detail</th>
                                    </tr>
                                </thead>
                                <tbody>

                                <?php $count=0; ?>
                                <?php foreach($emails as $email): $count++;?>
                                <tr>
                                    <td><?php echo $count; ?></td>
                                    <td><?php echo $email['Email']['title']?></td>
                                    <td><?php echo count($email['Customer'])?></td>
                                    <td>
                                        <?php
                                            $email_opended = 0;
                                            foreach ($email['Customer'] as $k){

                                                // if($v['customer'])
                                                // pr($v['CustomersEmail']['opened']);
                                                if($k['CustomersEmail']['opened'] == 1){

                                                    $email_opended += 1;
                                                }
                                            }
                                        echo $email_opended;
                                ?>
                            </td>
                            <td><?php echo $this->Html->link('View detail', array('controller'=>'emails', 'action'=>'view', 
                            $email['Email']['id']), array('id' => 'viewemail')) ;?></td>
                        </tr>
                    <?php endforeach ;?>
                    

                                </tbody>
                            </table>
                        </div>
                        <footer class="panel-footer">
                            <div class="row">
                                <div class="col-sm-4 hidden-xs">
                                    <button class="btn btn-danger">Delete Selected</button>
                                </div>

                                <div class="col-sm-3 text-center"><small class="text-muted inline m-t-small m-b-small">showing 20-30 of 50 items</small> </div>
                                <div class="col-sm-5 text-right text-center-sm">
                                    
                                    <ul class="pagination pagination-small m-t-none m-b-none">
                                        <?php
                                        	echo $this->Paginator->prev(__('prev'), array('tag' => 'li'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                                        	echo $this->Paginator->numbers(array('separator' => '','tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'active')); 
                                        	echo $this->Paginator->next(__('next'), array('tag' => 'li','currentClass' => 'disabled'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                                        ?>
                                    </ul>
                                </div>
                            </div>
                        </footer>
                    </section>
                </div>
            </div>
        </section>
</section>



